//
//  QSImage.swift
//  chat
//
//  Created by 1 on 2023/3/31.
//

import SwiftUI
import Kingfisher

struct QSImage: View {
    var string: String

    var body: some View {
        if let url = URL(string: string){
            //可优化缓存并加载
            KFImage(url)
                .resizable()
        }else{
            Rectangle().fill(Color(.gray).opacity(0.1))
        }
    }
}


struct QSImage_Previews: PreviewProvider {
    static var previews: some View {
        QSImage(string: "http://www.test.chaodanfan.com/img/imgBanner.png?v=2023")
//
            .aspectRatio(contentMode: .fit)
            .cornerRadius(20)
            .padding(.horizontal,24)
//            .clipShape(RoundedRectangle(cornerRadius: 8))
////                        .cornerRadius(8)
//            .padding(.top,24)
//            .padding(.bottom,8)
        
//        QSImage(string: "http://www.test.chaodanfan.com/img/imgBanner.png?v=2023")
//            .frame(width: 100,height: 100)
//            .cornerRadius(20)
    }
}
